<!--
Creator: Miroslav Milivojevic, Sofija Puric
-->
<?php

if (!(isset($_SESSION['username']) && $_SESSION['username']!=""))
     header('Location: hostels.php?err=6');
$uname = $_SESSION['username'];

require 'pages/db.php';
$con=dbConnect("sib");

$hid=$_GET["hid"];

$sql_exist_feedback = "SELECT * FROM feedback WHERE IDHostel = '$hid' AND IDUser =
(SELECT IDUser FROM user WHERE UserName = '$uname')";

$result_exist_feedback = mysql_query($sql_exist_feedback, $con);
if (!$result_exist_feedback)
    die('Error: ' . mysql_error());
if (mysql_num_rows($result_exist_feedback) > 0)
    header('Location: hostels.php?err=13');

$sql_user = "SELECT * FROM user WHERE username = '$uname'";
$result_user = mysql_query($sql_user, $con);
if (!$result_user)
    die('Error: ' . mysql_error());
else $row_user=mysql_fetch_array($result_user);
$uid = $row_user["IDUser"];

$sql_hostel = "SELECT * FROM hostel WHERE IDHostel = '$hid'";
$result_hostel = mysql_query($sql_hostel, $con);
if (!$result_hostel)
               die('Error: ' . mysql_error());
else $row_hostel=mysql_fetch_array($result_hostel);
$h_name = $row_hostel["Name"];


echo '<div class="rate_choice"><h1>'. $h_name.'</h1><br /><br /></div>';

echo '
<form name = "feedback_form" action =
      "pages/feedback_hostel.php?hid='.$hid.'&uid='.$uid.'" method = "post" align ="left">
      <div class="rate_choice">
        <table>
            <tr>
                <td colspan="2">Text: </td>
            </tr>
            <tr>
                <td colspan="2"><textarea name="text" rows="4" cols="50"></textarea></td>
            </tr>
            <tr>
                <td>Cleanliness: </td>
                <td>
                    <div id="cleanliness" class="rate_widget" >
                        <div class="star_1 ratings_stars" ></div>
                        <div class="star_2 ratings_stars" ></div>
                        <div class="star_3 ratings_stars" ></div>
                        <div class="star_4 ratings_stars" ></div>
                        <div class="star_5 ratings_stars" ></div>
                        <div class="total_votes" >vote data</div>
                        <input class="cleanliness" type="hidden" name="cleanliness" value="0">
                    </div>
                </td>
            </tr>

            <tr>
                <td>Price: </td>
                <td>
                    <div id="price" class="rate_widget" >
                        <div class="star_1 ratings_stars"></div>
                        <div class="star_2 ratings_stars"></div>
                        <div class="star_3 ratings_stars"></div>
                        <div class="star_4 ratings_stars"></div>
                        <div class="star_5 ratings_stars"></div>
                        <div class="total_votes">vote data</div>
                        <input class="price" type="hidden" name="price" value="0">
                    </div>
                </td>
            </tr>

            

            

            <tr>
                <td>Fun: </td>
                <td>
                    <div id="fun" class="rate_widget" >
                        <div class="star_1 ratings_stars"></div>
                        <div class="star_2 ratings_stars"></div>
                        <div class="star_3 ratings_stars"></div>
                        <div class="star_4 ratings_stars"></div>
                        <div class="star_5 ratings_stars"></div>
                        <div class="total_votes">vote data</div>
                        <input class="fun" type="hidden" name="fun" value="0">
                    </div>
                </td>
            </tr>
            <tr>
                <td>Service: </td>
                <td>
                    <div id="service" class="rate_widget" >
                        <div class="star_1 ratings_stars"></div>
                        <div class="star_2 ratings_stars"></div>
                        <div class="star_3 ratings_stars"></div>
                        <div class="star_4 ratings_stars"></div>
                        <div class="star_5 ratings_stars"></div>
                        <div class="total_votes">vote data</div>
                        <input class="service" type="hidden" name="service" value="0">
                    </div>
                </td>
            </tr>
            <tr>
                <td>Location: </td>
                <td>
                    <div id="location" class="rate_widget" >
                        <div class="star_1 ratings_stars"></div>
                        <div class="star_2 ratings_stars"></div>
                        <div class="star_3 ratings_stars"></div>
                        <div class="star_4 ratings_stars"></div>
                        <div class="star_5 ratings_stars"></div>
                        <div class="total_votes">vote data</div>
                        <input class="location" type="hidden" name="location" value="0">
                    </div>
                </td>
            </tr>
            <tr>
                <td>Security: </td>
                <td>
                    <div id="security" class="rate_widget" >
                        <div class="star_1 ratings_stars"></div>
                        <div class="star_2 ratings_stars"></div>
                        <div class="star_3 ratings_stars"></div>
                        <div class="star_4 ratings_stars"></div>
                        <div class="star_5 ratings_stars"></div>
                        <div class="total_votes">vote data</div>
                        <input class="security" type="hidden" name="security" value="0">
                    </div>
                </td>
            </tr>
            <tr>
                <td>Recommend:</td>
                <td><select name="score_recommend" size="1">

                       <option value="1">Yes</option>
                       <option value="2">No</option>
                        </select></td>
          </tr>
            <tr>
                <td colspan="2"><button type="submit">Feedback!</button></td>
            </tr>
        </table>
    </div>
</form>
';



    mysql_close($con);
?>



